﻿#include <iostream>
#include <thread>
#include <vector>
#include "../common/cworker_client.h"
#include "../common/cbase_msg.h"
#include "../common/clog.h"
#ifdef _WIN32
#include <Windows.h>
#pragma comment(lib, "ws2_32.lib")
#endif
using namespace std;

int main()
{
#ifdef _WIN32
	WSAData wsadata;
	WSAStartup(MAKEWORD(2, 2), &wsadata);
#endif
	vector<CAbstractWorkerClient*> cset;
	for (int i = 0; i < 1; ++i)
	{
		CAbstractWorkerClient *item = new CWorkerClient();
		item->set_server_ip("127.0.0.1");
		item->set_server_port(8000);
		item->Init();
		cset.push_back(item);
	}
	
	CBaseMsg msg(CMD_PING);
	strcpy(msg.username, "yunni");
	
	while (true)
	{
		for (auto &client : cset)
		{
			if (client->IsConnecting())
				client->SendData(&msg);
			//client.SendDataReal();
			client->Main();
		}
		
		LOG_DEBUG("发送消息\n");
		this_thread::sleep_for(1s);
	}
	return 0;
}
